<template>
  <div>
    <table>
      <tr>
        <td>工序编号</td>
        <td>
          <el-input
            v-model="from.Process_BianHao"
            placeholder="请输入内容"
          ></el-input>
        </td>
        &nbsp;
        <td>工序名称</td>
        <td>
          <el-input
            v-model="from.Process_Name"
            placeholder="请输入内容"
          ></el-input>
        </td>
      </tr>
      <br />
      <tr>
        <td>报工权限</td>
        <td>
          <el-select v-model="from.Reporting_Id" placeholder="请选择">
            <el-option
              v-for="item in GetResults"
              :key="item.Reporting_Id"
              :label="item.Reporting_Name"
              :value="item.Reporting_Id"
            >
            </el-option>
          </el-select>
        </td>
        &nbsp;
        <td>报工数配比</td>
        <td>
          <el-input
            v-model="from.Process_DuiBi"
            placeholder="请输入内容"
          ></el-input>
        </td>
      </tr>
      <br />
      <tr>
        <td>不良品项列表</td>
        <td>
          <el-select v-model="from.Defective_Id" placeholder="请选择">
            <el-option
              v-for="item in GetDefective"
              :key="item.Defective_Id"
              :label="item.Defective_Name"
              :value="item.Defective_Id"
            >
            </el-option>
          </el-select>
        </td>
      </tr>
      <tr>
        <td>
          <el-button type="success" @click="Add()">添加</el-button>
        </td>
      </tr>
    </table>
  </div>
</template>
<script>
export default {
  data() {
    return {
      GetResults: [], //报工
      GetDefective: [], //不良品项列表

      from: {
        Reporting_Id: "",
        Defective_Id: "",
        Process_BianHao: "",
        Process_Name: "",
        Process_DuiBi: "",
      },
    };
  },

  methods: {
    //报工
    ResultShow() {
      this.axios
        .get("http://localhost:5255/api/ProcEs/GetResult")
        .then((dx) => {
          this.GetResults = dx.data.Data;
        });
    },

    //不良品项列表
    DefectiveShow() {
      this.axios
        .get("http://localhost:5255/api/ProcEs/GetDefective")
        .then((dx) => {
          this.GetDefective = dx.data.Data;
        });
    },

    //添加
    Add() {
      this.axios
        .post("http://localhost:5255/api/ProcEs/ResultAdd", this.from)
        .then((cs) => {
          if (cs.data) {
            this.$message.success("添加成功");
            this.$emit("ProAdd");
          } else {
            this.$message.error("添加失败");
          }
        });
    },
  },
  created() {
    this.ResultShow();
    this.DefectiveShow();
  },
};
</script>
<style >
</style>
